//
//  BaseService.m
//  NewsReader
//
//  Created by blacksun on 11-2-16.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "BaseService.h"


@implementation BaseService
@synthesize delegate;
@synthesize activeRequest;
@synthesize appDelegate;



-(void) request:(id)aRequest successWithResult:(id)result andCommand:(int) aCommand{
	[self.activeRequest removeObjectForKey:aRequest];
	[self.delegate onServiceSuccess:result command:aCommand identifier:nil];
}
-(void) request:(id)aRequest failedWithStatuCode:(int) aStatuCode andCommand:(int) aCommand{
	[self.activeRequest removeObjectForKey:aRequest];
	[self.delegate onServiceFailure:aStatuCode command:aCommand identifier:nil];
}

-(id)initWithDelegate:(id)aDelegate{
	if (self=[super init]) {
		self.delegate = aDelegate;
		NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
		self.activeRequest = dict;
		[dict release];
		appDelegate = [UIApplication sharedApplication].delegate;
		return self;
	}
	return nil;
}

-(void) dealloc{
	self.delegate = nil;
	self.activeRequest = nil;
	[super dealloc];
}

@end
